/*
  Copy this file to create basic service with list, get, patch, create functions
  Replace the following strings:
  `Version` -> `YourModelInterFace` (the interface)
  `path` in url function
*/
import { api } from '../boot/axios'
import { RepairOrderPartVersion } from './type'

function url(s: string) {
  if (s==''){
    return ['/api/repairorderpartversions', ''].join('/')
  }
  return ['/api/repairorderpartversions', s.replace('/', ''), ''].join('/')
}

export async function list(){
  const res = await api({
    url: url(''),
    method: 'get',
  })
  return res.data as RepairOrderPartVersion[]
}

export async function get (id:number){
  const res = await api({
    url: url(''+id),
    method: 'get',
  })
  return res.data as RepairOrderPartVersion
}

export async function patch (id:number,data:Partial<RepairOrderPartVersion>={}){
  const res = await api({
    url: url(''+id),
    method: 'patch',
    data
  })
  return res.data as RepairOrderPartVersion
}

export async function create (data:Partial<RepairOrderPartVersion>={}){
  const res = await api({
    url: url(''),
    method: 'post',
    data
  })
  return res.data as RepairOrderPartVersion
}

export default { list, get, patch, create }